<template>
    <div>
        <el-select v-model="value" filterable remote reserve-keyword placeholder="请输入关键词搜索" :disabled="disabled" :remote-method="remoteMethod" :loading="loading" @change="selectChange">
            <el-option v-for="(item,index) in options" value-key="id" :key="index" :label="item.name" :value="item"></el-option>
        </el-select>
    </div>
</template>

<script>
import * as API from '@/api/business/map.js'
export default {
    name: 'OrgMap',
    data() {
        return {
            value:'',
            loading:false,
            options:[]
        }
    },
    props:{
        disabled:{
            type:Boolean,
            default: false
        }
    },
    methods:{
        remoteMethod(query){
            API.getPoiFromMap(query).then(res=>{
                if(res.status === 200){
                    this.options = res.data.tips
                }
            })
        },
        selectChange(value){
            console.log(value)
            this.$emit('map-serach',value)
        }
    }
}
</script>